﻿using CPF;
using CPF.Animation;
using CPF.Charts;
using CPF.Controls;
using CPF.Drawing;
using CPF.Mac.Foundation;
using CPF.Shapes;
using CPF.Styling;
using CPF.Svg;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CPFUI.IControl
{
    [CPF.Design.DesignerLoadStyle("res://$safeprojectname$/Stylesheet1.css")]//用于设计的时候加载样式
    public class TextBoxEx : TextBox
    {
        public TextBoxEx()
        {
            CornerRadius = "3";
            IsAntiAlias= true;
            BorderFill = "#DCDFE6";
            BorderStroke = new Stroke(1);
        }
        public bool IsSingleLine
        {
            get
            {
                return GetValue<bool>();
            }
            set
            {
                SetValue(value);
            }
        }
        //模板定义
        protected override void InitializeComponent()
        {
            base.InitializeComponent();
           
        }
        protected override void OnInitialized()
        {
            base.OnInitialized();
            
            Bindings.Add(nameof(TextBox.HScrollBarVisibility), nameof(IsSingleLine), this, BindingMode.OneWay, (x) => { return !(bool)x ? ScrollBarVisibility.Visible : ScrollBarVisibility.Hidden; });
            Bindings.Add(nameof(TextBox.VScrollBarVisibility), nameof(IsSingleLine), this, BindingMode.OneWay, (x) => { return !(bool)x ? ScrollBarVisibility.Visible : ScrollBarVisibility.Hidden; });
            Bindings.Add(nameof(TextBox.AcceptsReturn), nameof(IsSingleLine), this, BindingMode.OneWay, (x) => { return !(bool)x; });


        }
#if !DesignMode //用户代码写到这里，设计器下不执行，防止设计器出错
        //用户代码

#endif
    }
}
